# Copyright 2023 Ant Group Co., Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

load("//bazel:yacl.bzl", "AES_COPT_FLAGS", "yacl_cc_library", "yacl_cc_test")

package(default_visibility = ["//visibility:private"])

yacl_cc_library(
    name = "spi",
    srcs = ["gf_spi.cc"],
    hdrs = [
        "gf_scalar.h",
        "gf_spi.h",
        "gf_vector.h",
    ],
    deps = [
        "//yacl/io/msgpack:buffer",
        "//yacl/io/msgpack:spec_traits",
        "//yacl/math/galois_field:gf_interface",
        "//yacl/math/mpint",
        "//yacl/utils:parallel",
        "//yacl/utils/spi/sketch",
        "@com_google_absl//absl/types:span",
    ],
)

yacl_cc_library(
    name = "mcl_factory",
    srcs = [
        "mcl_factory.cc",
    ],
    hdrs = ["mcl_factory.h"],
    visibility = [
        "//yacl/crypto/pairing/factory:__pkg__",
        "//yacl/math/galois_field:__pkg__",
    ],  # grant visibility
    deps = [
        ":spi",
        "//yacl/crypto/ecc/mcl:util",
        "//yacl/crypto/pairing/factory:mcl_pairing_header",
    ],
    alwayslink = 1,
)

yacl_cc_test(
    name = "mcl_factory_test",
    srcs = ["mcl_factory_test.cc"],
    deps = [
        ":mcl_factory",
        "//yacl/crypto/rand",
    ],
)

yacl_cc_library(
    name = "mpint_factory",
    srcs = ["mpint_factory.cc"],
    hdrs = ["mpint_factory.h"],
    visibility = ["//yacl/math/galois_field:__pkg__"],  # grant visibility to main target
    deps = [
        ":spi",
    ],
    alwayslink = 1,
)

yacl_cc_test(
    name = "mpint_factory_test",
    srcs = ["mpint_factory_test.cc"],
    deps = [
        ":mpint_factory",
    ],
)

yacl_cc_library(
    name = "intel_factory",
    srcs = [
        "intel_factory.cc",
    ],
    hdrs = ["intel_factory.h"],
    copts = AES_COPT_FLAGS,
    visibility = ["//yacl/math/galois_field:__pkg__"],  # grant visibility to main target
    deps = [
        ":spi",
        "//yacl/base:block",
        "//yacl/base:exception",
        "//yacl/base:int128",
        "//yacl/crypto/rand",
        "@com_google_absl//absl/types:span",
    ],
    alwayslink = 1,
)

yacl_cc_test(
    name = "intel_factory_test",
    srcs = ["intel_factory_test.cc"],
    deps = [
        ":intel_factory",
    ],
)
